import {ControlType, FormBase} from './form-base';

export class FormUpload extends FormBase<string[]> {
    controlType: ControlType = 'upload';
    private _value = [];
    length = 24;
    type = 'default';

    get value() {
        return this._value;
    }

    set value(upload: any) {
        if (upload) {
            if (typeof upload === 'string') {
                this._value = JSON.parse(upload);
            } else {
                this._value = upload;
            }
        }
    }

    constructor(options: {} = {}) {
        super(options);
        this.type = options['type'] || 'default';
        if (options['value']) {
            if (typeof options['value'] === 'string') {
                this.value = JSON.parse(options['value']);
            } else {
                this.value = options['value'];
            }
        }
    }
}
